<template>
  <div class="app-container">
    <div class="formDiv">
      <el-form ref="form" :inline="true" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="订单号">
              <el-input v-model="params.nickname" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名/手机号">
              <el-input v-model="params.nickname" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="医院名称">
              <el-select
                clearable
                @clear="clearfn('hospitalId')"
                filterable
                v-model="params.hospitalId"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in officeOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="结算状态">
              <el-input v-model="params.nickname" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="上级姓名/手机号">
              <el-input v-model="params.nickname" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="核销时间">
              <el-date-picker
                v-model="time"
                type="daterange"
                value-format="yyyy-MM-dd HH:mm:ss"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :default-time="['00:00:00', '23:59:59']"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="结算时间">
              <el-date-picker
                v-model="time1"
                type="daterange"
                value-format="yyyy-MM-dd HH:mm:ss"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :default-time="['00:00:00', '23:59:59']"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-button style="margin-left:60px" type="primary" @click="searchFn">查询</el-button>
            <!-- 新加 -->
            <el-button style="margin-left:60px" type="primary" @click="exfun">导出</el-button>
            <el-button style="margin-left:60px" type="primary">批量结算</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="listDiv">
      <!-- {{$store.state.user.permissionJson}} -->
      <el-table
        :data="tableData"
        class="tableData"
        ref="multipleTable"
        @selection-change="handleSelectionChange"
        style="width: 100%"
      >
        <el-table-column type="selection" width="55" :selectable="selectable"></el-table-column>

        <el-table-column
          type="index"
          label="序号"
          fixed="left"
          align="center"
          :index="table_index"
          width="50"
        ></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button @click="checkfn(scope.row)" type="text">结算</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="params.page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="params.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
    <el-dialog
  title="提示"
  :visible.sync="dialogVisible"
  width="30%">
  <span>这是一段信息</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>
  </div>
</template>

<script>
import { hospitalDropDown } from "@/api/doctorManage";
import { exportfile } from "@/api/commjs/exprot";
export default {
  name: "",
  watch: {
    time(val) {
      this.params.createdAtStart = val ? val[0] : "";
      this.params.createdAtEnd = val ? val[1] : "";
    },
    time1(val) {
      this.params.createdAtStart = val ? val[0] : "";
      this.params.createdAtEnd = val ? val[1] : "";
    }
  },
  data() {
    return {
        dialogVisible:false,
      multipleSelection: [],
      total: 0,
      tableData: [{}],
      time: "",
      officeOption: [],
      time1: "",
      params: { page: 1, size: 10 }
    };
  },
  created() {
    this.hlist();
  },
  methods: {
      checkfn(data){
          console.log(data)
          this.dialogVisible= true
      },
    // 复选框禁用控制
    selectable(row, index) {
      if (row.auditStatus == "待审核") {
        return true;
      } else {
        return false;
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    searchFn() {
      this.params.page = 1;
      this.list();
    },
    hlist() {
      hospitalDropDown().then(res => {
        let resData = res.data.data;
        let newData = [];
        resData.forEach(e => {
          newData.push({
            value: e.id + "",
            label: e.name
          });
        });
        newData.unshift({
          value: "",
          label: "全部"
        });
        this.officeOption = newData;
        // console.log(this.officeOption)
      });
    },
    list() {},
    table_index(index) {
      return (this.params.page - 1) * this.params.size + index + 1;
    },
    handleSizeChange(val) {
      this.params.page = 1;
      this.params.size = val;
      this.list();
    },
    handleCurrentChange(val) {
      this.params.page = val;
      this.list();
    },
    exfun() {
      exportfile(
        "/com.mmk.reservation.api.AdminHospitalAccountProvider/1.0.0/hospitalAccountRechargeexport.html",
        this.params
      );
    }
  }
};
</script>
